/*var treeStyleJson = new Object();
treeStyleJson['Initial Isolate'] = 'background-color: white';
treeStyleJson['Homozygous Diploid'] = 'background-color: pink';
treeStyleJson['HO- Hemizygous'] = 'background-color: orange';
treeStyleJson['HO- Haploid'] = 'background-color: yellow';
treeStyleJson['SPS2-GFP Tagged KAN'] = 'background-color: lavender';
treeStyleJson['SPS2-GFP Tagged NAT'] = 'background-color: cyan';
treeStyleJson['KAN Haploid Candidate'] = 'background-color: lavender';
treeStyleJson['NAT Haploid Candidate'] = 'background-color: cyan';
treeStyleJson['Not Natural Variant'] = 'border: 3px dotted red';
treeStyleJson['Not S. cerevisiae'] = 'border: 3px dotted white';
treeStyleJson['Undetermined'] = 'border: 3px dotted black';
*/
var displayNonStatus = false;
var query, container, options;

function sendAndDraw() {
    query.abort();
    var tableQueryWrapper = new TableQueryWrapper(query, container, options);
    tableQueryWrapper.sendAndDraw();
}

function drawSeqSampleTable(yoHash) {

    //http://localhost:8080/google-dsapi-svc/addama/datasources/omics/omics_samples/query?tq=select%20*%20
    // where%20strains%20contains%20%27YO_300%27%20or%20strains%20contains%20%27YO_502%27&tqx=out:html
    // /query?tq=select%20*%20where%20sample_key%20=%20%27YO_8%27&tqx=out:html
    var strainName = yoHash.name;
    strainName = strainName.replace(/YO/, "YO_");
    var querySql = "select omics_type, omics_key, strains, status, key_meta where strains contains '" + strainName + "'";// where sample_key like 'YO*%'";//tableUri + "/google-ds-api";
    var query = new google.visualization.Query("/google-dsapi-svc/addama/datasources/omics/omics_samples/query?tq=" + querySql);
    var omicstable = new google.visualization.Table(document.getElementById('panel-properties'));
    query.send(function(response) {
        if (response.isError()) {
            Ext.Msg.alert("warning", "error at retrieving omics data for strain:" + strainName + "<br>" + response.getMessage());
            return;
        }
        var omicsdata = response.getDataTable();
        var rows = omicsdata.getNumberOfRows();
        if (rows > 0) {
            omicstable.draw(omicsdata, {
                showRowNumber: true,
                page: "enable",
                pageSize: 20,
                width: "100%",
                size: 'small',
                allowHtml: true
            });
            google.visualization.events.addListener(omicstable, 'select', function() {
                var row = omicstable.getSelection()[0].row;
                var otype = omicsdata.getValue(row, 1);
                var strains = omicsdata.getValue(row, 2);
                if (otype.indexOf("YIMG") != -1) {
                    var strainKey = strains.replace(/_/, " ");
                    loadImageWindow(strainKey);
                }
                if (otype.indexOf("YSEQ") != -1) {
                    mainPanel.activate(sequencingPanel);
                    Dudley.lims.YSEQEntry.setEntryLoaded(false);
                    Dudley.lims.YSEQEntry.setSearchParams(otype, "seqName");
                    Dudley.lims.YSEQEntry.loadGoSearch();
                }
                if (otype.indexOf("YCGS") != -1) {
                    mainPanel.activate(sequencingPanel);
                    sequencingPanel.activate();
                    Dudley.lims.YSEQCGS.setCGSLoaded(false);
                    Dudley.lims.YSEQCGS.setCGSSearchParams(otype, "All");
                    Dudley.lims.YSEQCGS.loadCGSSearch();
                }
                if (otype.indexOf("YCR") != -1) {
                    Dudley.lims.Crossing.setCrosssingLoaded(false);
                    Dudley.lims.Crossing.setCrossingSearchParams(otype, "All");
                    Dudley.lims.Crossing.loadCrossingSearch();
                }
            });
            metaPanel.expand();
            propertiesPanel.expand();
        } else {
            Ext.Msg.alert("info", "No omics data exists for strain:" + strainName);
        }
    });

}

